<template>
  <BasicCard>
    <BasicVxeTable v-bind="gridOptions"> </BasicVxeTable>
  </BasicCard>
</template>

<script setup lang="ts">
  import { columnsDetail } from '../data'
  import { getProductLocation } from '@/api/wms'

  const { t } = useI18n()

  const gridOptions = reactive<BasicGridProps>({
    extraConfig: {
      title: t('custom.货位详情'),
      isCustom: false,
      isExport: false,
      isFilterAndSort: true
    }, // 拓展的配置
    id: `kucunguanli-chengpinguanli-huoweixiangqing`, // id用于缓存,务必配置
    maxHeight: '100%',
    loading: true,
    columns: columnsDetail,
    toolbarConfig: {} // 工具栏
  })

  const getList = () => {
    getProductLocation()
      .then((res: any) => {
        gridOptions.loading = false
        const temp = res.productLocations
        temp.forEach((value) => {
          if (value.status == 3) {
            value.MaterialsCode = value.data[0].MaterialsCode
            value.ProductBatch = value.data[0].ProductBatch
            value.PackCount = value.data[0].PackCount
            value.Weight = value.data[0].Weight
            value.InDate = value.data[0].InDate
          }
        })
        temp.sort((a, b) => {
          return a.locationID.localeCompare(b.locationID, undefined, {
            numeric: true,
            sensitivity: 'base'
          })
        })
        gridOptions.data = temp
      })
      .catch(() => {
        gridOptions.loading = false
      })
  }

  onMounted(() => {
    getList()
  })
</script>
